//
//  UIView+Screenshot.m
//  test
//
//  Created by 任文超 on 15/1/8.
//  Copyright (c) 2015年 任文超. All rights reserved.
//

#import "UIView+Screenshot.h"

@implementation UIView (Screenshot)

- (UIImage*)screenshot {
    UIGraphicsBeginImageContext(self.bounds.size);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSData *imageData = UIImageJPEGRepresentation(image, 0.01);
    image = [UIImage imageWithData:imageData];
    
    return image;
}

@end
